<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>添加班级</title>
<link href="../css/bootstrap-cerulean.css" rel="stylesheet">
<link href="../css/charisma-app.css" rel="stylesheet">
<style type="text/css">
body {
	padding-bottom: 40px;
}

.sidebar-nav {
	padding: 9px 0;
}
</style>
	<script src="http://lib.sinaapp.com/js/jquery/2.2.4/jquery-2.2.4.min.js"></script>
	<script src="../js/common/public.js"></script>
	<script src="../js/base64.js"></script>
	<script src="../js/bootstrap-modal.js"></script>
	<script type="text/javascript">
		$(document).ready(function () {
			var urlMsg = parseUrl(window.location.search);
			$("#token").val(urlMsg.token);
			if (urlMsg.token != null) {
				var token = decode(urlMsg.token);
			}
			var year = $.ajax({
				type: "GET",
				url: "http://localhost:1068/admin/class/findAllClassNumber?token=" + token,
				async: false
			}).responseText;
			var yearReuslt = eval('(' + year + ')');
			if (yearReuslt.code != 200) {
				alert(yearReuslt.msg)
			} else {
				if (yearReuslt.data != null) {
					for (index in yearReuslt.data) {
						$("#year").append("<option value='" + yearReuslt.data[index] + "'>" + yearReuslt.data[index] + "</option>")
					}
				}
			}
		});



		function addClass() {
			var urlMsg = parseUrl(window.location.search);
			var classNumber = $("#classNumber").val();
			var className = $("#className").val();
			var majorName = $("#majorName").val();
			var monitor = $("#monitor").val();
			var year = $("#year").val();

			if (urlMsg.token != null) {
				var token = decode(urlMsg.token);
				token = token.substring(0, token.length - 1);
			}
			var year = $.ajax({
				type: "POST",
				url: "http://localhost:1068/admin/class/addClass",
				data:{token:token,classNumber:classNumber,className:className,majorName:majorName,monitor:monitor,year:year},
				async: false
			}).responseText;
			var yearReuslt = eval('(' + year + ')');
			if (yearReuslt.code != 200) {
				alert(yearReuslt.msg)
			} else {
				alert("添加成功！")
			}
		}
	</script>
</head>

<body>
	<div class="container-fluid"
		style="padding-left:0px;padding-right:2px;">
		<div class="row-fluid">
			<div id="content" class="span10" style="width:100%;">
				<div class="row-fluid sortable">
					<div class="box span12">
						<div class="box-header well">
							<h2>
								<i class="icon-edit"></i>添加班级信息
							</h2>
						</div>
						<div class="box-content" style="text-align:center; padding-top:50px">
							<form action="" method="post">
							<fieldset>
								<h1>添加班级信息</h1>
								<br><br>
							  <div class="control-group">
								<div class="controls">
								  <span style="font-size:14px">班级代号：</span><input name="classnumber" class="input" id="classNumber" type="text" style="height:30px;">
								</div>
							  </div>
							  <br>
							  <div class="control-group">
								<div class="controls">
								  <span style="font-size:14px">班级名称：</span><input name="classname" class="input" id="className" type="text" style="height:30px;">
								</div>
							  </div>
							  <br>
							  <div class="control-group">
								<div class="controls">
								  <span style="font-size:14px">专业名称：</span><input name="majorname" class="input" id="majorName" type="text" style="height:30px;">
							  </div>
								<br>
							  </div>
							  <div class="control-group">
								<div class="controls">
								  <span style="font-size:14px">班长姓名：</span><input name="monitor" class="input" id="monitor" type="text" style="height:30px;">
								</div>
							  </div>
							  <br>
							  <div class="control-group">
								<div class="controls">
								  <span style="font-size:14px">班级年级：</span>
								  <select name="year"  id="year" style="width:210px;">



								  </select>
								</div>
							  </div>
							  <br>
							  
							  <div class="form-actions">
								<button type="button" onclick="addClass()" class="btn btn-primary" style="width:100px;">提交</button>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<button class="btn"  onclick="javascript:history.go(-1);" type="reset" style="width:100px;">取消</button>
							  </div>
							</fieldset>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>